<?php get_header(); ?>
<div class="container">
<?php $id=get_query_var('cat'); ?>
	<div class="col-lg-3 col-md-3 news-cat">
	  <div class="news-catlist">
		<div class="news-button"><a href="<?php echo get_category_link(get_category_root_id($id)); ?>"><button class="news-cate-single btn btn-primary" type="button">所有文章(<?php echo gamux_get_allfirst_posts(get_category_root_id($id))+get_category(get_category_root_id($id))->count; ?>)
		</button></a>
		</div>
		<?php
		$categories=get_categories(array(
		  'orderby' => 'id',
		  'order' => 'ASC',
		  'parent' => get_category_root_id($id)
		  ));
		?>
		<?php //实现所有二级分类
		  foreach($categories as $category) {
			echo '<div class="news-button"><a href="'.get_category_link( $category->term_id ).'"><button class="news-cate-single btn btn-default">'. $category->name.'('.$category->count.')</button></a></div>';
		  }
		?>
	  </div>
	</div>
	<div class="col-lg-9 col-md-9 news-main">
		<div class="newsofcat">
		当前分类：<?php single_cat_title(); ?>
		</div>
		<div class="news-list">
		<?php if (have_posts()) : ?>
		<?php while (have_posts()) : the_post(); ?>
		<li class="news-single modal-content-hack">
			<div class="news-thumb">
				<img class="img-thumbnail" src="<?php echo src_post_thumbnail(); ?>">
			</div>
			<div class="news-body">
				<div class="news-title">
					<span class="news-title-body">
						<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
					</span>
					<span class="news-title-date right">
						<?php echo get_the_date('Y-m-d'); ?>
					</span>					
					<span class="news-title-author right">
						<?php echo '作者:'.get_the_author(); ?>
					</span>
					<span class="news-title-comment right">
					<?php echo '评论'.get_post($post->ID)->comment_count.'条'; ?>
					</span>
				</div>
				<div class="news-content">
				<?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 280,'...'); ?>
				</div>
			</div>
			<div class="clear"></div>
		</li>
		<?php endwhile; ?>  
		<?php endif; ?>
		</div>
		<div class="navi">
			<div class="navi-p"><?php next_posts_link("<button type='button' class='btn btn-primary'>较旧文章>></button>"); ?></div>
			<div class="navi-n"><?php previous_posts_link("<button type='button' class='btn btn-primary'><<较新文章</button>"); ?></div>
			<div class="clear"></div>
		</div>
	</div>
</div>
<link href="<?php bloginfo('template_url'); ?>/css/archive.css" rel="stylesheet">
<?php get_footer(); ?>